/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package SteamEngineDB;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jeff Bendixsen <jeff@westcoastcode.com>
 */
@Entity
@Table(name = "SCHEDULE_RUN")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ScheduleRun.findAll", query = "SELECT s FROM ScheduleRun s"),
    @NamedQuery(name = "ScheduleRun.findById", query = "SELECT s FROM ScheduleRun s WHERE s.id = :id"),
    @NamedQuery(name = "ScheduleRun.findByRunTime", query = "SELECT s FROM ScheduleRun s WHERE s.runTime = :runTime")})
public class ScheduleRun implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "RUN_TIME")
    @Temporal(TemporalType.TIME)
    private Date runTime;
    @JoinColumn(name = "SCHEDULE_ID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Schedule scheduleId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "runId")
    private Collection<ScheduleCar> scheduleCarCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "runId")
    private Collection<Reservation> reservationCollection;

    public ScheduleRun() {
    }

    public ScheduleRun(Integer id) {
        this.id = id;
    }

    public ScheduleRun(Integer id, Date runTime) {
        this.id = id;
        this.runTime = runTime;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getRunTime() {
        return runTime;
    }

    public void setRunTime(Date runTime) {
        this.runTime = runTime;
    }

    public Schedule getScheduleId() {
        return scheduleId;
    }

    public void setScheduleId(Schedule scheduleId) {
        this.scheduleId = scheduleId;
    }

    @XmlTransient
    public Collection<ScheduleCar> getScheduleCarCollection() {
        return scheduleCarCollection;
    }

    public void setScheduleCarCollection(Collection<ScheduleCar> scheduleCarCollection) {
        this.scheduleCarCollection = scheduleCarCollection;
    }

    @XmlTransient
    public Collection<Reservation> getReservationCollection() {
        return reservationCollection;
    }

    public void setReservationCollection(Collection<Reservation> reservationCollection) {
        this.reservationCollection = reservationCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ScheduleRun)) {
            return false;
        }
        ScheduleRun other = (ScheduleRun) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "SteamEngineDB.ScheduleRun[ id=" + id + " ]";
    }
    
}
